<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="com.AccountManage.model.User,com.AccountManage.util.*,java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="head.jsp" />
<title>欢迎来到账号租赁系统</title>

</head>
<body>
	<div class="container text-c">
		<!-- 容器，内部字体居中 -->
		<div class="row cl f-20">
			<div class="col-xs-2">
				<strong>账号租赁系统</strong>
			</div>
			<div class="col-xs-8">&nbsp</div>
			<div class="col-xs-1">
				<a href="#"> <!-- 获取session中的用户对象，显示用户名 --> <%
					User user = (User)session.getAttribute("user");
					if(user != null){
					%> <%=user.getName() %> <%
					}
					%>
				</a>
			</div>
			<div class="col-xs-1">
				<a href="user_logoutAction.do"> 注销 </a>
			</div>
		</div>
		
	<aside class="Hui-aside">
		<input runat="server" id="divScrollValue" type="hidden" value="" />
		<div class="menu_dropdown bk_2">
			<dl id="menu_notes">
				<dt>&nbsp;&nbsp;&nbsp;&nbsp;租赁账号<i class="Hui-iconfont menu_dropdown-arrow">&#xe6d5;</i></dt>
				<dd>
					<ul>
						<li><a href="user_account_xunlei.jsp">&nbsp;&nbsp;&nbsp;&nbsp;迅雷</a></li>
						<li><a href="user_account_aiqiyi.jsp">&nbsp;&nbsp;&nbsp;&nbsp;爱奇艺</a></li>
						<li><a href="user_account_youku.jsp">&nbsp;&nbsp;&nbsp;&nbsp;优酷</a></li>
					</ul>
				</dd>
			</dl>
			<ul>
				<li><a href="#">&nbsp;&nbsp;&nbsp;&nbsp;归还账号</a></li>
			</ul>
			<ul>
				<li><a href="user_account_history.jsp">&nbsp;&nbsp;&nbsp;&nbsp;租赁记录</a></li>
			</ul>
			<ul>
				<li><a href="user_activity.jsp">&nbsp;&nbsp;&nbsp;&nbsp;精彩活动</a></li>
			</ul>
			<ul>
				<li><a href="user_feedback.jsp">&nbsp;&nbsp;&nbsp;&nbsp;反馈问题</a></li>
			</ul>
			<ul>
				<li><a href="user_info.jsp">&nbsp;&nbsp;&nbsp;&nbsp;我的信息</a></li>
			</ul>
		</div>
	</aside>
		
	<section class="Hui-article-box">
	<form action="user_accountreturnAction.do" method="post">
		<table class="table table-border table-bordered table-hover">
			<thead>
				<tr>
					<th>账号编号</th>
					<td>账号昵称</td>
					<td>等级</td>
					<td>平台</td>
					<td>租赁时间</td>
					<td>租赁价格</td>
					<td>操作</td>
				</tr>
			</thead>
			<tbody>
				<%!Connection conn = null;%>
				<%!PreparedStatement psmt = null;%>
				<%!ResultSet rs = null;%>
				<%
					try {
						// 创建数据库连接
						conn = DBUtil.getConnection();
						String sql = "select *from user_account,account,platform_account,platform where "+
							"user_account.user_id = ? and user_account.account_id = account.id and account.id = platform_account.account_id and platform_account.plat_id = platform.id";
						// 预编译sql
						psmt = conn.prepareStatement(sql);
						psmt.setInt(1,user.getId());
						// 执行此查询操作
						ResultSet rs = null;
						rs = psmt.executeQuery();
						// 查询到记录，则该账户名的用户存在，flag为true
						while (rs.next()) {
							if(rs.getTimestamp("user_account.lend_time").getTime() == rs.getTimestamp("user_account.return_time").getTime()){
				%>
				<tr>
					<th><%=rs.getInt("account.id")%></th>
					<td><%=rs.getString("account.name") %></td>
					<td><%=rs.getInt("account.level") %></td>
					<td><%=rs.getString("platform.name") %></td>
					<td><%=rs.getTimestamp("user_account.lend_time") %></td>
					<td>0.25</td>
					<td>
					<input class="radius btn-primary" type="submit" value="归还" id=<%=rs.getInt("account.id") %> onclick="save(this)">
					</td>
				</tr>
				<%
							}
					}
					} catch (SQLException e) {
						e.printStackTrace();
						throw new AppException("vip_myAccount.jsp");
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
						throw new AppException("vip_myAccount.jsp");
					} finally {
						// 关闭数据库查询结果集
						DBUtil.closeResultSet(rs);
						// 关闭数据库查询指令
						DBUtil.closeStatement(psmt);
						// 关闭数据库连接
						DBUtil.closeConnection(conn);
					}
				%>
			</tbody>
		</table>
		<input type="hidden" id="hiddenText" name="hidden" value="">
		</form>
		</section>
		<jsp:include page="foot.jsp" />
		<script type="text/javascript">
		$(function(){
			$("#menu_notes dt").addClass("selected");$("#menu_notes dd").show();;
			$(".Hui-aside").scrollTop(566);	
		});
		function save(obj){
			//alert(obj.id);
			document.getElementById("hiddenText").value = obj.id;
			//alert(document.getElementById("hiddenText").value);
		}
		</script> 
	</div>
</body>
</html>